<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UserUpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username'=>[
                        'required',
                        'max:11',
                        'min:11',
                        'string',
                        'regex:/^1[3456789]\d{9}$/',
                        Rule::unique('user')->ignore(request()->input('id')),
            ],
            'password'=>'nullable|min:6|max:16|string',
            'nickname'=>'required|max:20|string',
            'company_name'=>[
                            'required',
                            'max:50',
                            'string',
                            Rule::unique('user')->ignore(request()->input('id')),
            ],
            'status'=>[
                'required',
                Rule::in([0,1])
            ]
        ];
    }

    public function attributes()
    {
        return [
            'username'=>'电话',
        ];
    }
}
